home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / mlib / examples / example2.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-16  |  1.3 KB  |  54 lines

  1. #include <mio.h>
  2. #include <mgr.h>
  3.  
  4. #define SPEED                1
  5.  
  6. RECT SampleBox (20,20,300,160);
  7.  
  8. /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
  9.   int              main ()
  10. /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
  11. {
  12. MMob * Flyer;
  13. MImage FlyerImage (50,50);
  14. int n;
  15. int dx = SPEED, dy = SPEED;
  16. MPal myPal;
  17.  
  18.     initgraph();
  19.     myPal.Update();
  20.     myPal.FadeOut();
  21.  
  22.     for (n = 25; n > 0; -- n)
  23.     {
  24.        setcolor (n + 30);
  25.        circle (25,25,n);
  26.     }
  27.     FlyerImage.Get (0,0);
  28.  
  29.     setfillstyle (SOLID_FILL, 76);   // Clear the screen
  30.     bar (gr.vp.left, gr.vp.top, gr.vp.right, gr.vp.bottom);
  31.     setviewport (SampleBox);
  32.     setfillstyle (SOLID_FILL, 80);   // Clear viewport
  33.     bar (gr.vp.left, gr.vp.top, gr.vp.right, gr.vp.bottom);
  34.  
  35.     Flyer = new MMob (100, 100, &FlyerImage);
  36.     Flyer->SetPut (SEETH_PUT);
  37.     myPal.FadeIn();
  38.  
  39.     keyb.KeyFlush();
  40.  
  41.     while (!keyb.KeyPress())
  42.     {
  43.        Flyer->MoveTo (Flyer->x() + dx, Flyer->y() + dy);
  44.        if ((Flyer->x() <= 0) || (Flyer->x() >= MAXX - FlyerImage.GetLength()))
  45.       dx = -dx;
  46.        if ((Flyer->y() <= 0) || (Flyer->y() >= MAXY - FlyerImage.GetWidth()))
  47.       dy = -dy;
  48.     }
  49.     delete Flyer;
  50.     myPal.FadeOut();
  51.     closegraph();
  52.     return (0);
  53. }
  54.